package com.iyundao.io.mapper;

import com.iyundao.io.model.PartyMemberOrganization;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.Date;

@Repository
public interface PartyMemberOrganizationMapper {
    @Insert({
        "insert into partymemberorganization (id, partymemberid, ",
        "organizationid, jointime, ",
        "outtime)",
        "values (#{id,jdbcType=INTEGER}, #{partymemberid,jdbcType=INTEGER}, ",
        "#{organizationid,jdbcType=VARCHAR}, #{jointime,jdbcType=DATE}, ",
        "#{outtime,jdbcType=DATE})"
    })
    int insert(PartyMemberOrganization record);

    @InsertProvider(type= PartyMemberOrganizationSqlProvider.class, method="insertSelective")
    int insertSelective(PartyMemberOrganization record);

    @Update("update partymemberorganization set outtime=#{outtime,jdbcType=DATE} where id=#{id,jdbcType=INTEGER}")
    int rollOut(Date outtime, Integer id);

    @Select("select organizationid from partymemberorganization where outtime='' and partymemberid=#{partymemberid,jdbcType=INTEGER}")
    int selectByPartymemberId(Integer partymemberid);
}